#include<bits/stdc++.h>
#define int long long
using namespace std;
int T,n,m,L,V;
int d[100001];
struct node{
    int d,v,a;
}a[100001];
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;
        memset(a,0,sizeof(a));
        memset(d,0,sizeof(d));
        for(int i=1;i<=n;i++)cin >> a[i].d >> a[i].v >> a[i].a;
        for(int i=1;i<=m;i++)cin >> d[i];
        int maxk=d[m];
        int ans1=0;
        for(int i=1;i<=n;i++)
            if(2*a[i].a*(maxk-a[i].d)+a[i].v*a[i].v>V*V&&a[i].d<=maxk)ans1++;
        if(ans1==0)m++;
        cout<<ans1<<" "<<m-1<<endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}